package com.example.botany_api.service;

import com.example.botany_api.bean.Gallery;
import com.example.botany_api.bean.GalleryType;
import com.example.botany_api.bean.User;
import com.example.botany_api.mapper.GalleryMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sun.rmi.runtime.Log;

import java.util.List;

/**
 * @Author 漫画忧作
 * @Date 2022/10/31 20:37
 * @Version 1.0
 */
@Service
public class GalleryService {
    @Autowired
    GalleryMapper galleryMapper;

    //    分页
    public List getGalleryType(String type_name, int current, int size) {
        return galleryMapper.getGalleryType(type_name, current, size);
    }

    //    总数
    public int getGalleryTypeTotal(String type_name) {
        return galleryMapper.getGalleryTypeTotal(type_name);
    }

    //    删除分类
    public int dl_GalleryType(int id) {
        return galleryMapper.dl_GalleryType(id);
    }


    //    添加分类
    public int add_GalleryType(GalleryType galleryType) {
        return galleryMapper.add_GalleryType(galleryType);
    }

    //    修改分类
    public int up_GalleryType(GalleryType galleryType) {
        return galleryMapper.up_GalleryType(galleryType);
    }

    //    管理员植物图库
//    分页
    public List getGallery(String name, String address, int type_id, int current, int size) {
        return galleryMapper.getGallery(name, address, type_id, current, size);
    }

    //    总数
    public int getGalleryTotal(String name, String address, int type_id) {
        return galleryMapper.getGalleryTotal(name, address, type_id);
    }

    //    删除植物图库
    public int dl_Gallery(int id) {
        return galleryMapper.dl_Gallery(id);
    }


    //    添加植物图库
    public int add_Gallery(Gallery gallery) {
        return galleryMapper.add_Gallery(gallery);
    }

    //    修改植物图库
    public int up_Gallery(Gallery gallery) {
        return galleryMapper.up_Gallery(gallery);
    }

    public List getOptionList() {
        return galleryMapper.getOptionList();
    }

    //推荐阅读
    public List getGalleryListCollect() {
        return galleryMapper.getGalleryListCollect();
    }

    public List galleryAndType(int id) {
        return galleryMapper.galleryAndType(id);
    }

    public int AddViews(int id) {
        return galleryMapper.AddViews(id);
    }

    public int isGalleryAddSave(int g_id, int u_id) {
        return galleryMapper.isGalleryAddSave(g_id, u_id);
    }

    public int galleryAddSave(int g_id, int u_id) {
//        增加收藏量
        galleryMapper.galleryAddCollect(g_id);
        return galleryMapper.galleryAddSave(g_id, u_id);
    }

    public int galleryCancelSave(int g_id, int u_id) {
        return galleryMapper.galleryCancelSave(g_id, u_id);
    }

    public List galleryListSave(int u_id) {
        return galleryMapper.galleryListSave(u_id);
    }

    public int selectMap(int id, String address, String lng, String lat) {
        return galleryMapper.selectMap(id, address, lng, lat);
    }
    public List getLatLngNameId(String lng, String lat){
        System.out.println("Ss"+lng);
        System.out.println("Ss"+lat);
        return galleryMapper.getLatLngNameId( lng, lat);
    }
}
